package com.example.superinbox;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class NewPlane extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_new_plane);

		// handle back button
		// currently navigate to previouse page with a message
		// handle add new plane activity
		final Button backButton = (Button) findViewById(R.id.plane_back);
		backButton.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				Intent intent = new Intent(getApplicationContext(), SMSPlane.class);
				startActivity(intent);
			}
		});

		// Save button give a popup message for now
		final Button saveButton = (Button) findViewById(R.id.save_plane);
		saveButton.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				// pop up
				showPopUp2("Saving..");
			}
		});
		
		// delete button give a popup message for now
		final Button deleteButton = (Button) findViewById(R.id.delete_plane);
		deleteButton.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				// pop up
				showPopUp2("Are you want to delete ? ");
			}
		});
		
		final Button newCategoryButton = (Button) findViewById(R.id.add_new_category);
		newCategoryButton.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				Intent intent = new Intent(getApplicationContext(), NewCategory.class);
				startActivity(intent);
			}
		});
		
	}

	private void showPopUp2(String text) {

		AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
		helpBuilder.setTitle("Title");
		helpBuilder.setMessage(text);
		
		helpBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {

			public void onClick(DialogInterface dialog, int which) {
				// Do nothing but close the dialog
			}
		});

		// Remember, create doesn't show the dialog
		AlertDialog helpDialog = helpBuilder.create();
		helpDialog.show();

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_new_plane, menu);
		return true;
	}

}
